package com.lvmama.rhino.collector.vo

import com.lvmama.rhino.collector.utils.Constants

/**
  * Created by yuanxiaofeng on 2016/3/11.
  */
class ClientLog extends Serializable{
  /**
    * appVersion
    * 客户端版本
    */
  var _av: String = _
  /**
    * mobileModel
    * 客户端机型
    */
  var _mm: String = _
  /**
    * deviceToken
    * 设备号
    */
  var _dt: String = _
  /**
    * eventLog列表
    * 事件log列表
    */
  var _ll: List[EventLog] = _

  def ll = _ll
  def av = _av
  def mm = _mm
  def dt = _dt

  def ll_= (v: List[EventLog]):Unit = _ll = v
  def av_= (v: String):Unit = _av = v
  def mm_= (v: String):Unit = _mm = v
  def dt_= (v: String):Unit = _dt = v

  override def toString: String = {
    val builder: StringBuilder = new StringBuilder
    if (ll != null) {
      for (eventLog <- ll) {
        builder.append(if (av != null) av else "").append(Constants.LOG_SEPERATOR_1)
        builder.append(if (mm != null) mm else "").append(Constants.LOG_SEPERATOR_1)
        builder.append(if (dt != null) dt else "").append(Constants.LOG_SEPERATOR_1)
        builder.append(eventLog.toString)
        if (eventLog != ll.last) {
          builder.append(System.lineSeparator())
        }
      }
    } else {
      builder.append(if (av != null) av else "").append(Constants.LOG_SEPERATOR_1)
      builder.append(if (mm != null) mm else "").append(Constants.LOG_SEPERATOR_1)
      builder.append(if (dt != null) dt else "").append(Constants.LOG_SEPERATOR_1)
    }
    builder.toString
  }
}
